package org.demo.ws;

import java.net.URL;

import org.codehaus.xfire.client.Client;

/**
 * 
 * @author  
 * @date    2011-1-7
 * @file    org.demo.ws.XFireProxy.java
 */
public class XFireProxy {
	
	/**
	 * 测试
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		String wsdlLocation = "http://localhost:8080/axis2/services/HelloServiceTest?wsdl";
		String methodName = "detail";
		Object[] params = new Object[]{12, 1234, 12.01, 12.02, "hello"};
		
		XFireProxy proxy = new XFireProxy();
		String result = proxy.invoke(wsdlLocation, methodName, params);
		System.out.println(result);
	}
	/**
	 * 
	 * @param wsdlLocation
	 * @param methodName
	 * @param args
	 * @return
	 * @throws Exception 
	 */
	public String invoke(String wsdlLocation, String methodName, Object[] args) throws Exception{
		Client client = new Client(new URL(wsdlLocation));	
		client.setEndpointUri("http://localhost:8080/axis2/services/HelloServiceTest.HelloServiceTestHttpSoap11Endpoint/");
		Object[] results = client.invoke(methodName, args);
		
		String result = null;
		if (results != null){
			result = String.valueOf(results[0]);
		}
		return result;
	}
}
